//
//  NavigationBoot.swift
//  SwiftUIWidgetDemo
//
//  Created by alanzhangg on 2023/7/15.
//

import SwiftUI

struct NavigationBoot: View {
    var body: some View {
        NavigationView {
            ScrollView {
                NavigationLink("hello") {
                    MyOtherScreen()
                }
                
                Text("Hello world")
                Text("Hello world")
                Text("Hello world")
                Text("Hello world")
            }
            .navigationTitle("all inboxs")
            .toolbar(content: {
                ToolbarItemGroup(placement: .topBarLeading) {
                    Image(systemName: "person.fill")
                        .foregroundStyle(.red)
                }
                ToolbarItemGroup(placement: .topBarTrailing) {
                    NavigationLink {
                        MyOtherScreen()
                    } label: {
                        Image(systemName: "gear")
                            
                    }

                }
            })

        }
        
    }
}

struct MyOtherScreen: View {
    
    @Environment(\.dismiss) var dismiss;
    
    var body: some View{
        ZStack{
            Color.green
                .ignoresSafeArea()
                .navigationTitle("second")
                .toolbar(.hidden, for: .navigationBar)
            
            VStack(content: {
                
                Button("back") {
                    dismiss()
                }
                
                NavigationLink("click") {
                    Text("3rd screen")
                }
            })
            
        }
    }
}

#Preview {
    NavigationBoot()
}
